﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using Tank.Resources;

namespace Tank.Role
{
    public class Bullet
    {
        private Data.Direction indexDirection;
        private bool idnexStop = false;
        private Data.BulletType indexType;
        public Point indexPoint;
        private int speed;//速度
        /// <summary>
        /// 当前运动方向
        /// </summary>
        public Tank.Data.Direction IndexDirection
        {
            get { return indexDirection; }
            set { indexDirection = value; }
        }

        /// <summary>
        /// 获取当前子弹样式
        /// </summary>
        public Data.BulletType IndexType
        {
            get { return indexType; }
        }
        /// <summary>
        /// 当前子弹是否停止 true停止
        /// </summary>
        public bool IdnexStop
        {
            get { return idnexStop; }
            set { idnexStop = value; }
        }

        /// <summary>
        /// 子弹类
        /// </summary>
        /// <param name="dir">方向</param>
        /// <param name="BulletType">子弹样式</param>
        /// <param name="p">npc坐标</param>
        public Bullet(Data.Direction dir,Tank.Data.BulletType BulletType, Point p)
        {
            this.indexDirection = dir;
            this.indexType = BulletType;
            this.indexPoint = p;
            speed = 7;//最大值不能超过子弹的长宽 子弹长宽为坦克长宽4分之1
        }

        /// <summary>
        /// 获取子弹图标
        /// </summary>
        /// <returns></returns>
        public Image getImage()
        {
            switch (IndexType)
            {
                case Data.BulletType.NpcBullet:
                    return ImageResources.NPCBullet;
                case Data.BulletType.PlayBullet:
                    return ImageResources.PlayBullet;
                default :
                    return ImageResources.PlayBullet;
            }
        }

        /// <summary>
        /// 获取子弹坐标
        /// </summary>
        /// <returns></returns>
        public Point getPoint()
        {
            if (Data.BulletMove && idnexStop == false)
            {
                indexPoint = new TankCollision().getBulletPoint(indexDirection, indexPoint, indexType, speed);
            }
            return indexPoint;
        }
    }
}
